package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ClientAccepterThread implements Runnable {
	
	private int port;
	
	public ClientAccepterThread(int port) {
		super();
		this.port = port;
	}
	
	@Override
	public void run() {
		ExecutorService es = Executors.newCachedThreadPool();
		try {
			ServerSocket socket = new ServerSocket(port);
			while (true) {
				Socket s = socket.accept();
				es.execute(new ClientThread(s));
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
